<?php
//echo 'Add product';
@$act = $_GET['act'];
@$id = $_GET['id'];

if(@$act == 'edit')
{
	$getdata = $exec_mysql->execute("select * from node where id = $id",0);
	$row2 = mysql_fetch_array($getdata);
	
	$ed = 'edit';
}


$loai_sp = $exec_mysql->execute("select * from category",0);
?>

<script type="text/javascript">
function checkSubmit(){
	if($('#txtTitle_vi').val() == ''){
		showAlert('Lỗi', 'Vui lòng nhập tiêu đề!', 'txtTitle_vi');
		return false;
	}
			
}
</script>

<p class="group-line">
   <span class="group-title">Thêm sản phẩm</span>
</p>
<div id="frmAdd">
<form name="frmAddNode" action="admin_master_page.php?cmd=3.2" method="post" enctype="multipart/form-data" onsubmit="return checkSubmit()">
    <table class="form-layout" width="650px" border="0px">
        <tr>
            <td width="150px">Loại sản phẩm</td>
            <td>
                <select name="selLoai" id="selLoai">
                    <?php
					while($row = mysql_fetch_array($loai_sp))
					{
						if(isset($row2['id_ref']))
						{
							if($row2['id_ref'] == $row['id'])
							{
								//$sp = 'selected="selected"';
								echo '<option selected="selected" value="'.$row['id'].'">'.$row['name_vi'].' / '.$row['name_en'].'</option>';
							}
						}
						echo '<option value="'.$row['id'].'">'.$row['name_vi'].' / '.$row['name_en'].'</option>';
					}
					?>
                </select>
            </td>
        </tr>
        <tr>
            <td>Tiêu đề / Title</td>
            <td>
            	<input type="text" name="txtTitle_vi" id="txtTitle_vi" style="width:485px; margin-bottom:3px" value="<?php echo @$row2['title_vi']; ?>" />
                <input type="text" name="txtTitle_en" id="txtTitle_en" style="width:485px" value="<?php echo @$row2['title_en']; ?>" />
            </td>
        </tr>
        <tr>
            <td>Hình minh họa</td>
            <td><input type="file" name="txtPic" id="txtPic" />
            <?php
				if(isset($row2['img']))
				{
					echo '<img src="'.$row2['img'].'" width="100px">';
				}
			?>
           </td>
        </tr>
        
        <tr>
            <td colspan="2">
            	<textarea name="txtCont_vi" id="txtCont_vi" rows="4"><?php echo @$row2['content_vi']; ?></textarea>
                <textarea name="txtCont_en" id="txtCont_en" rows="4"><?php echo @$row2['content_en']; ?></textarea>
            </td>
            <script>
				CKEDITOR.replace( 'txtCont_vi',{
					enterMode: CKEDITOR.ENTER_BR
				});
				CKEDITOR.replace( 'txtCont_en',{
					enterMode: CKEDITOR.ENTER_BR
				});
            </script>
        </tr>
    </table>
    <p class="footer-form">
    	<input type="hidden" name="txtEdit" value="<?php echo @$ed; ?>" />
        <input type="hidden" name="txtIdEdit" value="<?php echo @$id; ?>" />
    	<input type="submit" name="btnSave" value="Lưu" />
        <input type="reset" name="btnDelete" value="Xóa" />
    </p>
</form>
</div>
